package com.wyx.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class regExp06 {
    public static void main(String[] args) {
       String content = "王艺锡你好 王艺锡666 王艺锡777";
       //1.分别找到王艺锡你好，王艺锡666，王艺锡777子字符串
       //String regStr = "王艺锡你好|王艺锡666|王艺锡777";//方法1
        //String regStr ="王艺锡(?:你好|666|777)";//方法2

        //2.分别找到王艺锡你好中的王艺锡，王艺锡666中的王艺锡
        //String regStr ="王艺锡(?=你好|666)";

        //3.找到除王艺锡你好中的王艺锡，王艺锡666中的王艺锡之外的王艺锡
        String regStr ="王艺锡(?!你好|666)";

        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()){
            System.out.println("找到" + matcher.group(0));
        }
    }
}
